package howe.sudoku.listener;

import howe.sudoku.layout.KeypadDialog;
import howe.sudoku.layout.PuzzleView;
import android.view.View;
import android.view.View.OnClickListener;

public class KeyPadNumListener implements OnClickListener {

    private KeypadDialog keypadDialog = null;

    private PuzzleView puzzleView = null;

    private int iNumNo = 0;

    public KeyPadNumListener(KeypadDialog keypadDialog,
                             PuzzleView puzzleView,
                             int iNumNo) {
        this.keypadDialog = keypadDialog;
        this.puzzleView = puzzleView;
        this.iNumNo = iNumNo;
    }

    @Override
    public void onClick(View v) {
        returnResult(this.iNumNo);
    }

    private void returnResult(int tile) {
        puzzleView.setSelectedTile(tile);
        keypadDialog.dismiss();
    }
}
